﻿using System;
using System.Collections.Generic;
using chromium.HTTP.Parser;

namespace chromium.HTTP.Runtime
{
    public class HandlerContext
    {
        private readonly HttpRequest request;
        private readonly HttpResponse response;
        private readonly AsyncCallback callback;
        private HanlderReult result = HanlderReult.Failed;
        private List<Exception> errors = new List<Exception>();

        public HandlerContext(HttpRequest request, HttpResponse response, AsyncCallback callback)
        {
            this.request = request;
            this.response = response;
            this.callback = callback;
        }

        public HttpRequest Request
        {
            get { return request; }
        }

        public HttpResponse Response
        {
            get { return response; }
        }

        public HanlderReult Result
        {
            get { return result; }
            set { result = value; }
        }

        public void AddException(Exception e)
        {
            errors.Add(e);
        }

        public void PerformCallback()
        {
            if (callback != null)
                callback(null);
        }
    }
}
